import util from "@/libs/util";

export default ({ request }) => ({
  /**
   * @description 个人中心
   * @param {Object} data
   */
  USERS_CENTER() {
    let userinfo = util.store.getItem("userinfo");
    return request({
      url: "/data/v1/personalCenter",
      method: "post",
      data: {
        id: userinfo.user_id,
      },
    });
  },
  /**
   * @description 资料修改
   * @param {Object} data
   */
  EDIT_USERINFO(data = {}) {
    return request({
      url: "/data/v1/personalDataEdit",
      method: "post",
      data: data,
    });
  },
  /**
   * @description 密码修改
   * @param {Object} data
   */
  EDIT_PWD(data = {}) {
    return request({
      url: "/data/v1/passwordEdit",
      method: "post",
      data: data,
    });
  },
  /**
   * 验证token
   * @returns
   */
  CHECK_TOKEN() {
    const token = util.store.getItem("token") || null;
    return request({
      url: "/data/v1/tokenverification",
      method: "post",
      data: token,
    });
  },
  /**
   * 反馈投诉
   * @returns
   */
  USER_FEEDBACK(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;

    return request({
      url: "/data/v1/complaint",
      method: "post",
      data: data,
    });
  },
  /**
   * 产品需求
   * @returns
   */
  PRODUCT_DEMAND(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;

    return request({
      url: "/data/v1/demand",
      method: "post",
      data: data,
    });
  },
  HISTORY_SEARCH(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.user_id = userinfo.user_id;
    return request({
      url: "/data/v1/historySearch",
      method: "post",
      data: data,
    });
  },
  HISTORY_SEARCH_DELETE(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.user_id = userinfo.user_id;
    return request({
      url: "/data/v1/historySearchDelete",
      method: "post",
      data: data,
    });
  },
});
